//
//  movieTableViewCell.m
//  movie
//
//  Created by 李丹阳 on 15/7/20.
//  Copyright (c) 2015年 李丹阳. All rights reserved.
//

#import "movieTableViewCell.h"

@implementation movieTableViewCell

- (void)awakeFromNib {
    // Initialization code
    self.starView = [[starView alloc]initWithFrame:CGRectMake(105, 37, 111, 21)];

    self.selectionStyle = UITableViewCellSelectionStyleNone;
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {


    // Configure the view for the selected state
}

- (void)setModal:(movieModal *)modal{
    _modal = modal;
    self.starView.average = modal.average;
    [self setNeedsLayout];
}

- (void)layoutSubviews{
    _titleLabel.text = _modal.title;
    _yearLabel.text = [NSString stringWithFormat:@"年份: %@",_modal.year];
    //_modal.year;
    _averageLabel.text = [NSString stringWithFormat:@"%.1f",_modal.average ];
    NSString *imageStr = [_modal.image objectForKey:@"large"];
    [_iconImageView sd_setImageWithURL:[NSURL URLWithString:imageStr]];
    
    
//    self.starView = [[starView alloc]initWithFrame:CGRectMake(105, 37, 111, 21)];
    
    [self.contentView addSubview:self.starView];
    
    
//    [self addStarLabel];

}
//- (void)addStarLabel{
//    
//    
//    UIImage* yellowStar = [UIImage imageNamed:@"yellow"];
//    UIImage* grayStar = [UIImage imageNamed:@"gray@2x"];
//    
//    UIView* yellowStarView = [[UIView alloc]initWithFrame:CGRectMake(105, 37,yellowStar.size.width*(self.modal.average)*0.5 , yellowStar.size.height)];
//    UIView* grayStarView = [[UIView alloc]initWithFrame:CGRectMake(105, 37, yellowStar.size.width*5, yellowStar.size.height)];
//    
//    yellowStarView.backgroundColor = [UIColor colorWithPatternImage:yellowStar];
//    grayStarView .backgroundColor = [UIColor colorWithPatternImage:grayStar];
//
//    [self.contentView addSubview:grayStarView];
//    [self.contentView addSubview:yellowStarView];
//}

@end
